/**
 * Created by xml on 2019/1/2.
 */
import * as types from '../../store/types'
import api from '../../axios'
import dateformat from '../../resource/dateformat-es6.js'

export default {
    name: 'order',
    mounted() {
        this.loaded = false;
        this.getOrders(3);
        this.getProducts();
        var date = dateformat.format(new Date(), 'yyyy-MM-dd hh:mm:ss');
        this.time = date;
        //console.log(date)
    },
    methods: {
        handleSetLineChartData(type) {
            this.$emit('handleSetLineChartData', type)
        },
        buyProduct(obj) {
            this.$router.push({
                path: '/product',
                name: 'product',
                params: {
                    product: obj
                }
            })
        },
        getProducts() {
            api.hGet("/api/product/list", "", (data) => {
                if (data.success) {
                    this.content = data.data;
                }
            });
            console.log(this.content);
        },
        getOrders(pageSize) {
            //let timer=new Date().getTime().toString();
            let url = '/api/order/myOrders?pageSize=' + pageSize;

            api.hPost(url, "", (data) => {
                if (data.success) {
                    this.orders = data.data;
                }
                if (pageSize == null && this.orders.length == 3) {
                    this.$message.info("已到底部...");
                }
                this.loaded = true;
            });
        },

        //了解订单详情
        personal(data) {
            //this.$message.info("敬请期待...");
            this.$router.push({
                name: 'orderDetail',
                params: {
                    data: data
                }
            });

        },

        //跳转链接
        skip(companyId, productId)
        {
            //人脸识别
            let module = 'persons';
            //图像识别
            if (productId == 2) {
                module = 'media';
            }//视频会议
            else if (productId == 4) {
                module = 'videoConference';
            }

            this.$router.push({
                name: module,
                params: {
                    companyId: companyId,
                    productId: productId
                }

            });
        },
    },
    data() {
        return {
            img: [
                require('../../assets/facerecognition.png'),
                require('../../assets/imagerecognition.png'),
                require('../../assets/topmeeting.png')
            ],
            productImg: [
                require('../../assets/face-rec.png'),
                require('../../assets/img-rec.png'),
                require('../../assets/remote.png')
            ],
            content: '',
            orders: '',
            time: '',
            loading: false,
            pageInfo: {
                currentPage: 1,
                pageSize: 4,
                totalNum: 0
            },
            loaded: false,
            browser: navigator.userAgent
        }
    }
}